<template>
  <div class="">
    <div class="header">我的网校列表</div>
    <div class="body">
      <div class="btn">
        <el-button
          class="addwang"
          size="middle"
          type="primary"
          icon="el-icon-edit"
          >添加网校</el-button
        >
      </div>
      <el-row :gutter="16">
        <el-col :span="8" v-for="item in schoolList" :key="item.id">
          <el-card shadow="hover">
            {{ item.name }}
            <el-link
              type="primary"
              :underline="false"
              @click="ToSchool(item.id)"
              >管理</el-link
            >
          </el-card>
        </el-col>
      </el-row>
    </div>
    <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page"
      :page-sizes="[10, 20, 30, 50]"
      :page-size="size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { setItem } from "../../utils/storage";
import { myMeshing } from "../../api/meshing";
export default {
  data() {
    return {
      page: 1,
      size: 20,
      schoolList: [],
      total: 0,
    };
  },
  created() {
    this.getMeshing();
    console.log(this.$store.getters);
  },
  mounted() {},
  methods: {
    async getMeshing() {
      let res = await myMeshing(this.page, this.size);
      console.log(res.data.data);
      this.schoolList = res.data.data.items;
      this.total = res.data.data.total;
    },
    handleSizeChange(newSize) {
      this.size = newSize;
      this.getMeshing();
    },
    handleCurrentChange(newPage) {
      this.page = newPage;
      this.getMeshing();
    },
    ToSchool(id) {
      console.log(id);
      setItem("sc", id);
      this.$router.push("/layout");
    },
  },
  components: {},
};
</script>

<style lang='scss'>
.header {
  height: 10px;
  line-height: 10px;
  padding: 20px;
  box-shadow: 0 0 0 1;
}
.btn{
  padding-bottom: 10px;
}
.el-card__body{
  height: 68px;
  line-height: 28px;
}
.el-link {
  // padding: 7px 0;
  font-size: 12px;
  vertical-align: middle;
  float: right;
  // margin-bottom: 3px;
}
.addwang {
  margin: 0 0 10px 10px;
  padding-bottom: 10px;
}
.body {
  padding: 20px;
}
.el-col {
  margin-bottom: 10px;
}
.el-pagination {
  margin: 30px 0 0;
  padding: 32px 16px;
}
</style>
